package com.zl.springcloudfeignserver.controller;

import com.zl.springcloudfeignserver.EurekaClient;
import com.zl.springcloudfeignserver.EurekaClientFallbackFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: ZhangLiang
 * @Date: 2021/08/23/22:27
 * @Description:
 */
@RestController
public class HiController {

   private final EurekaClient eurekaClient;
   private final EurekaClientFallbackFactory eurekaClientFallbackFactory;

    public HiController(@Qualifier("com.zl.springcloudfeignserver.EurekaClient") EurekaClient eurekaClient, EurekaClientFallbackFactory eurekaClientFallbackFactory) {
        this.eurekaClient = eurekaClient;
        this.eurekaClientFallbackFactory = eurekaClientFallbackFactory;
    }

    @GetMapping(value = "/hi")
    public String sayHi(@RequestParam String name){
        return  eurekaClient.sayHiFromClientOne(name);
    }

    @GetMapping(value = "/hi/factory")
    public String sayHiFactory(@RequestParam String name){
        return  eurekaClientFallbackFactory.sayHiFromClientOne(name);
    }
}
